package top.serms.leetcode;

/**
 * @Author: SerMs
 * @Date: 2024/07/05 09 06
 * @Email: 1839928782@qq.com
 * @Blog: https://serms.top
 **/
public class LeetCode3033 {


    public static int[][] modifiedMatrix(int[][] matrix) {
        int n = matrix.length;
        int m = matrix[0].length;
        for (int i = 0; i < m; i++) {
            int maxNumber = -1;
            for (int[] ints : matrix) {
                maxNumber = Math.max(maxNumber, ints[i]);
            }
//            for (int j = 0; j < n; j++) {
//                maxNumber = Math.max(maxNumber, matrix[j][i]);
//            }
            for (int k = 0; k < n; k++) {
                if (matrix[k][i] == -1) {
                    matrix[k][i] = maxNumber;
                }
            }
        }
        return matrix;
    }


    public static void main(String[] args) {
        int[][] matrix = {{1, 2, -1}, {4, -1, 6}, {7, 8, 9}};
        int[][] modifieded = modifiedMatrix(matrix);
//        for (int i = 0; i < modifieded.length; i++) {
//            for (int j = 0; j < modifieded.length; j++) {
//                System.out.print(modifieded[i][j] + " ");
//            }
//            System.out.println();
//        }

    }
}
